/*
 *  Copyright 2010 UPF Telecos 4th group G.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package edu.upf.core;

import edu.upf.content.DescriptionContent;
import edu.upf.messages.SearchResult;
import edu.upf.utils.Definitions;


/**
 * Class that permits all the DB funcionality. It represents the model in MVC
 * model.
 * @author asustatil
 */
public class DatabaseManager implements Definitions {

    ClientLogic clientLogic;

    /**
     * Database manager constructor, receives a clientLogic instance for
     * callbacks
     * @param clientLogic
     */
    public DatabaseManager(ClientLogic clientLogic){
        this.clientLogic=clientLogic;
    }

    /**
     * Gets the results of a given query in the form of a SearchResult object
     * @param queryType
     * @param query
     * @return
     */
    public SearchResult getQueryResults(String queryType, String query){
        return getTestResult(query);
    }

    /**
     * Generates a 'mock' result when no database is available
     * @param query
     * @return
     */
    public SearchResult getTestResult(String query){
        SearchResult result= new SearchResult(query);
        result.addContent(new DescriptionContent(IMAGE, SIZE, POPULARITY,
                NAME,clientLogic.getUserName(),PATH));
        return result;
    }
}
